My general recomendation is plotly.
ggplot object and automatically convert it.library(plotly)
p <- ggplot(mtcars, aes(mpg, disp, col = as.factor(gear))) +
geom_point()
ggplotly(p)We use this on for Trendlocks Forecast - Bat Country, but its a new
suppressPackageStartupMessages(library(highcharter))
highchart() %>%
hc_chart(type = "line") %>%
hc_title(text = "Monthly Average Temperature") %>%
hc_subtitle(text = "Source: WorldClimate.com") %>%
hc_xAxis(categories = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) %>%
hc_yAxis(title = list(text = "Temperature (C)")) %>%
hc_plotOptions(line = list(
dataLabels = list(enabled = TRUE),
enableMouseTracking = T)
) %>%
hc_series(
list(
name = "Tokyo",
data = c(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6)
),
list(
name = "London",
data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8)
)
)This method ports a Javascript library to R. It’s light, interactive and has some crazy plotting types but it’s still in an experimental stage, so probably not stable enought to use…
library(r2d3)
r2d3(d3_version = 4, script = "js/voronoi.js")What if we could have a static and interactive plot side by side? Maybe a simple soloution is to have two idential plots side by side so that even when you zoom in on one, the other is there for reference. Depends on your intended use I guess.
p1 <- plot_ly(economics, x = ~date, y = ~unemploy) %>%
add_lines(color = "red")
subplot(p1, p1)## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels